package com.hz.common.view;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.WindowManager;

import io.gitee.hongzhenw.R;

public class LoadingDialog extends ProgressDialog {

    private boolean isCircle;

    public LoadingDialog(Context context, boolean isCircle) {
        this(context, 0, isCircle);
    }

    public LoadingDialog(Context context, int theme, boolean isCircle) {
        super(context, theme);
        this.isCircle = isCircle;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(isCircle ? R.layout.loading_cirle : R.layout.loading_rect);
        // 布局大小
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);
        // 背景透明
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
    }
}
